home *** CD-ROM | disk | FTP | other *** search
/ Champak 132 (Alt) / Vol 132.iso / games / nameless.swf / scripts / DefineSprite_62_mc_cam / frame_1 / DoAction.as
Encoding:
Text File  |  2011-06-09  |  1.6 KB  |  74 lines

  1. function camControl()
  2. {
  3.    parentColor.setTransform(camColor.getTransform());
  4.    var _loc5_ = sX / this._width;
  5.    var _loc4_ = sY / this._height;
  6.    _parent._x = cX - this._x * _loc5_;
  7.    _parent._y = cY - this._y * _loc4_;
  8.    _parent._xscale = 100 * _loc5_;
  9.    _parent._yscale = 100 * _loc4_;
  10.    friction = 10;
  11.    if(!setVars)
  12.    {
  13.       xPlus = 0;
  14.       maxPlus = 120;
  15.       xSpeed = 10;
  16.       setVars = true;
  17.    }
  18.    if(_root.cm.die == false)
  19.    {
  20.       if(Key.isDown(39))
  21.       {
  22.          xPlus += xSpeed;
  23.       }
  24.       else if(Key.isDown(37))
  25.       {
  26.          if(_root.level != 6)
  27.          {
  28.             xPlus -= xSpeed;
  29.          }
  30.       }
  31.    }
  32.    else
  33.    {
  34.       xPlus = 0;
  35.    }
  36.    if(xPlus > maxPlus)
  37.    {
  38.       xPlus = maxPlus;
  39.    }
  40.    else if(xPlus < - maxPlus)
  41.    {
  42.       xPlus = - maxPlus;
  43.    }
  44.    if(_root.level != 2)
  45.    {
  46.       _X = _X + ((_root.cm._x + xPlus - _X) / friction + shakeX);
  47.       _Y = _Y + ((_root.cm._y - 120 - _Y) / friction + shakeY);
  48.    }
  49. }
  50. function resetStage()
  51. {
  52.    var _loc2_ = {ra:100,rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0};
  53.    parentColor.setTransform(_loc2_);
  54.    _parent._xscale = 100;
  55.    _parent._yscale = 100;
  56.    _parent._x = 0;
  57.    _parent._y = 0;
  58. }
  59. shakeX = 0;
  60. shakeY = 0;
  61. _visible = false;
  62. var oldMode = Stage.scaleMode;
  63. Stage.scaleMode = "exactFit";
  64. var cX = Stage.width / 2;
  65. var cY = Stage.height / 2;
  66. var sX = Stage.width;
  67. var sY = Stage.height;
  68. Stage.scaleMode = oldMode;
  69. var camColor = new Color(this);
  70. var parentColor = new Color(_parent);
  71. this.onEnterFrame = camControl;
  72. camControl();
  73. this.onUnload = resetStage;
  74.